﻿<Window x:Class="DaphneTranslatorWPF.View.NewFileDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:view="clr-namespace:DaphneTranslatorWPF.View"              
        Title="Enter the new file properties" Height="340"  MaxHeight="340" MinHeight="340" Width="500"
        WindowStartupLocation="CenterOwner"
        WindowStyle="ToolWindow"
        Background="{DynamicResource WindowBackgroundBrush}"
         Padding="3">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <GroupBox Header="File creation type:" Grid.Row="0" Grid.Column="0" Padding="3" Margin="3">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <RadioButton x:Name="rbNewAssoc" Content="Create a new file association" GroupName="CreationType" 
                                Grid.Row="0" Margin="3" IsChecked="{Binding Path=NewAssocChecked}"/>
                <RadioButton x:Name="rbExistAssoc" Content="Attach to an existing file association" GroupName="CreationType" 
                                Grid.Row="1" Margin="3" IsChecked="{Binding Path=ExistingAssocChecked}"/>
            </Grid>            
        </GroupBox>

        <GroupBox Header="File path" Grid.Row="1" Margin="3">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition  Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Text="{Binding Path=PathViewModel.RootPath}" />
                <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right"></TextBlock>
                <TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Relative path:</TextBlock>
                <view:PathSelection Grid.Row="1" Grid.Column="1" Margin="3" DataContext="{Binding Path=PathViewModel}"/>
            </Grid>
        </GroupBox>

        <Grid Grid.Row="2" Margin="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition/>                                   
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0">Filename:</TextBlock>
            <TextBox Grid.Column="1" Text="{Binding Path=FileName}">
                <TextBox.Style>
                    <Style TargetType="TextBox">
                        <Style.Triggers>
                            <DataTrigger  Binding="{Binding Path=IsChecked, ElementName=rbNewAssoc}" Value="True">
                                <Setter Property="IsEnabled" Value="True" />
                            </DataTrigger  >
                            <DataTrigger Binding="{Binding Path=IsChecked, ElementName=rbNewAssoc}" Value="False">
                                <Setter Property="IsEnabled" Value="False" />
                            </DataTrigger>
                        </Style.Triggers>                        
                    </Style>                    
                </TextBox.Style>                
            </TextBox>
            <TextBlock Grid.Column="2">.xml</TextBlock>                         
        </Grid>

        <GroupBox Header="Existing File Association" Grid.Row="3" Padding="3" Margin="3">
            <ComboBox ItemsSource="{Binding Path=ExistingFiles}">
                <ComboBox.Style>
                    <Style TargetType="ComboBox">
                        <Style.Triggers>
                            <DataTrigger  Binding="{Binding Path=IsChecked, ElementName=rbExistAssoc}" Value="True">
                                <Setter Property="IsEnabled" Value="True" />
                            </DataTrigger  >
                            <DataTrigger Binding="{Binding Path=IsChecked, ElementName=rbExistAssoc}" Value="False">
                                <Setter Property="IsEnabled" Value="False" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ComboBox.Style>                
            </ComboBox>
        </GroupBox>
        <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" >
            <Button IsDefault="True" Margin="3" Height="25" Click="Button_Click">OK</Button>
            <Button IsCancel="True" Margin="3" Height="25">Cancel</Button>
            
        </StackPanel>                     
    </Grid>
</Window>
